package com.example.tnorder.controller;

import com.yc.vo.Result;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import java.time.LocalDateTime;


@RestController
@RequestMapping("order")
public class OrderController {
    @Resource
    private RedisTemplate redisTemplate;

    @PostMapping("redirect")
    public ModelAndView redirect(){
        return new ModelAndView("redirect:/test1.html");
    }

    @GetMapping("get")
    public Result get(){
        Long size = redisTemplate.opsForSet().size(LocalDateTime.now().toString().substring(0, 10));
        Integer i=0;
        if (size!=null){
           i= Math.toIntExact(size);
        }
        return Result.success("success",i);
    }
}
